<template>

    
        <div class="log_sty">
              <div><van-nav-bar left-arrow title="交易密码"  @click-left="$router.go(-1)" /></div>
            <!-- <div title><div></div><div>为保证您的资产安全，请设置交易密码！</div></div> -->
            
            <div con>
                <p>请输入您的密码确认发币</p>
                <div>
                    <van-password-input  :value="pwd" :length="6"  :focused="showKeyboard" @focus="showKeyboard = true; status=1"  gutter=".8rem"  />
                </div>

               
              
                <div>
                    <van-number-keyboard :show="showKeyboard" extra-key="" maxlength="2" close-button-text="完成" @blur="showKeyboard = false" @input="onInput" @delete="onDelete" transition   hide-on-click-outside
                  />
                </div>
                
              <div class="but_sty sms_sty_o"> <van-button type="primary" @click="next" >下一步</van-button></div>
            </div>
           

        </div>


</template>

<script>
export default {
 name: "login",
data() {
    return {
          status:'',
                pwd:'',
                showKeyboard:false,
                r_pwd:'',
    }
},
 mounted() { 
   let that=this;
    that.base.head_status(1)
  },
 methods: {
                    onInput(key) {
                    console.log(this.status)
                    if(this.status==1){
                        this.pwd = (this.pwd + key).slice(0, 6);
                    }
                    },
                    onDelete() {
                    if(this.status==1){
                            this.pwd = this.pwd.slice(0, this.pwd.length - 1);
                    }
                    
                    },
                next() {
                    var that=this;
                    if(that.pwd.length!=6){
                         that.$toast({ message: "请输入六位数的交易密码" });
                            return
                    }
                  

                  if(that.$route.params.type=="sellaffirmdeal"){
                           var data={token:JSON.parse(localStorage.userinfo).token,id:that.$route.params.uid,pay_passwd:that.pwd}
                        that._API.sellaffirmdeal(data).then(res => {
                           

                               that.$dialog.alert({title: '提示信息', message: res.msg }).then(() => {
                                 if(res.code==200){
                                     that.$router.go(-2)
                                 }
                                });
                          
                          }).catch(err => {  
                             that.$dialog.alert({title: '提示信息', message: "网络请求失败,请稍后再试" }).then(() => { });
                        });
                  }else if(that.$route.params.type=="transfer"){

                        that.$dialog.confirm({ title: '提示信息',message: '确定要转账到此用户吗'}).then(() => {  
                     
                   that.$toast.loading({ message: '加载中...', forbidClick: true,overlay:true});
                    var data={token:JSON.parse(localStorage.userinfo).token,'mobile':that.$route.params.mobile,'azcnumber':that.$route.params.azcnumber,pay_passwd:that.pwd}
                          that.$toast.clear();
                            that._API.transfer(data,that).then(res => {

                                  that.$dialog.alert({title: '提示信息', message: res.msg }).then(() => {
                                    if(res.code==200){
                                       that.$router.go(-2)
                                      }
                                });
                                
                                
                              }).catch(err => {
                                  that.$dialog.alert({title: '提示信息', message: "网络请求失败,请稍后再试" }).then(() => { });
                              });
                      }).catch(() => {
                  // on cancel
                  });

                  }else if(that.$route.params.type=="Balance"){

                            that.$dialog.confirm({ title: '提示信息',message: '确定要转账到我的资产吗'}).then(() => {  
                     
                            that.$toast.loading({ message: '加载中...', forbidClick: true,overlay:true});
                        var data={token:JSON.parse(localStorage.userinfo).token,'balance':that.$route.params.balance,pay_passwd:that.pwd}
                              that.$toast.clear();
                                that._API.Balance(data,that).then(res => {

                                      that.$dialog.alert({title: '提示信息', message: res.msg }).then(() => {
                                        if(res.code==200){
                                           that.$router.go(-2)
                                          }
                                    });
                                    
                                    
                                  }).catch(err => {
                                      that.$dialog.alert({title: '提示信息', message: "网络请求失败,请稍后再试" }).then(() => { });
                                  });
                          }).catch(() => {
                      // on cancel
                      });
                  }else if(that.$route.params.type=='usdtransfer'){

                      that.$dialog.confirm({ title: '提示信息',message: '确定要转账到此用户吗'}).then(() => {  
                     
                          that.$toast.loading({ message: '加载中...', forbidClick: true,overlay:true});
                      var data={token:JSON.parse(localStorage.userinfo).token,'touserurl':that.$route.params.touserurl,'usdtnumber':that.$route.params.usdtnumber,pay_passwd:that.pwd}
                            that.$toast.clear();
                              that._API.usdtransfer(data,that).then(res => {

                                    that.$dialog.alert({title: '提示信息', message: res.msg }).then(() => {
                                      if(res.code==200){
                                       that.$router.go(-2)
                                        }
                                  });
                                  
                                  
                                }).catch(err => {
                                    console.log("err", err);
                                });
                        }).catch(() => {
                    // on cancel
                    });
                  }else if(that.$route.params.type=='exchange'){

                          that.$dialog.confirm({ title: '提示信息',message: '确定要把USDT兑换成AZC吗'}).then(() => {

                   var data={token:JSON.parse(localStorage.userinfo).token,"usdtnumber":that.$route.params.usdtnumber ,pay_passwd:that.pwd}

                        that.$toast.loading({ message: '加载中...', forbidClick: true,overlay:true});
                        that._API.exchange(data).then(res => {
                             that.$toast.clear();
                                  that.$dialog.alert({title: '提示信息', message: res.msg }).then(() => {
                                      if(res.code==200){
                                       that.$router.go(-2)
                                        }
                                  });

                            }).catch(err => {
                                     that.$dialog.alert({title: '提示信息', message: "网络请求失败,请稍后再试" }).then(() => { });

                               
                            });
          
            }).catch(() => {
            // on cancel
            });
                  }


             
                      
                      
                 

                },
           
                
                log_author(){
                  
                }


      }
}
</script>


<style lang="scss" scoped >



    /deep/.van-password-input__security{    justify-content: center;}
    /deep/.van-nav-bar{background-color: initial;}
    /deep/.van-nav-bar .van-icon,/deep/.van-uploader__upload-text,/deep/.van-nav-bar__title{color:white}

    .log_sty [title]>div:nth-child(1){text-align: center;font-size: 1.5rem;}
    .log_sty [title]>div:nth-child(2){text-align: center;font-size: 0.8rem;line-height: 2rem;}

    .log_sty [con]>p{line-height: 5rem;    margin: 0 16px;font-size: .8rem}
    .but_sty{text-align: center;    margin-top: 10%;}
    .but_sty button{width: 60%;border: 0;border-radius: 0.5rem;    border-radius: 2rem;} 
    /deep/.but_sty .van-button--primary{background: #831BFA;}
    /deep/.van-key{color: black;}
    /deep/.van-password-input__security li{    border: 1px solid;background-color: initial;border-radius: 0.1rem;      height: 2rem;width: 2rem;flex: initial}

    /deep/.van-password-input__security i{    background-color: white;}
    /deep/.van-toast--html, .van-toast--text{background-color: white};
    /deep/.van-toast__text{color:black}
</style>
